﻿#ifndef ETHERNET_H
#define ETHERNET_H

#include <QObject>
#include <QTcpSocket>
#include "device.h"
#include "TCPSubClient.h"

class Ethernet : public Device
{
    Q_OBJECT
public:
    explicit Ethernet(QObject *parent = nullptr);

    QString strIP() const;
    void setStrIP(const QString &newStrIP);
    int nPort() const;
    void setNPort(int newNPort);

private:
    TCPSubClient*       tcpSubClient;

public:
    virtual void writeXML(QXmlStreamWriter &writer) override;
    virtual void readFromXML(QXmlStreamReader &reader) override;
    virtual int initDevice() override;
    virtual void writeData(const QVariant &data) override;
    virtual void uninitDevice() override;
    virtual QString getClassName() override;

signals:
    void        strIPChanged();
    void        nPortChanged();

private:
    QString             m_strIP;
    int                 m_nPort;

    Q_PROPERTY(QString strIP READ strIP WRITE setStrIP NOTIFY strIPChanged FINAL)
    Q_PROPERTY(int nPort READ nPort WRITE setNPort NOTIFY nPortChanged FINAL)
};

#endif // ETHERNET_H
